﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RM2012Server.Model;
using System.Data;
using RM2012Server.Business;
using System.Windows.Forms;

namespace RM2012Server.Controller
{
    public class InvoiceDetailCtrl
    {
        InvoiceDetailDAO m_InvoiceDetailDAO = new InvoiceDetailDAO();

        public List<InvoiceDetailStateInfo> DetailStateSources()
        {
            List<InvoiceDetailStateInfo> list = new List<InvoiceDetailStateInfo>();
            list.Add(new InvoiceDetailStateInfo(true, "Đã phục vụ"));
            list.Add(new InvoiceDetailStateInfo(false, "Đang chế biến"));
            return list;
        }

        public void LoadToDataGridViewComboBoxColumnState(DataGridViewComboBoxColumn cmb)
        {
            cmb.DataSource = DetailStateSources();
            cmb.DisplayMember = "StateName";
            cmb.ValueMember = "State";
            cmb.DataPropertyName = "State";
            cmb.HeaderText = "Trạng thái";
        }

        public DataTable GetAll()
        {
            return m_InvoiceDetailDAO.GetAll();
        }

        public DataTable GetByInvoiceId(String invoiceId)
        {
            return m_InvoiceDetailDAO.GetByInvoiceId(invoiceId);
        }

        public DataTable GetFullByInvoiceId(String invoiceId)
        {
            return m_InvoiceDetailDAO.GetFullByInvoiceId(invoiceId);
        }

        public DataTable GetReportByInvoiceId(String invoiceId)
        {
            return m_InvoiceDetailDAO.GetReportByInvoiceId(invoiceId);
        }

        public DataTable GetByMenuId(String menuId)
        {
            return m_InvoiceDetailDAO.GetByMenuId(menuId);
        }

        public DataTable GetByMenuAndInvoice(String invoiceId, String menuId)
        {
            return m_InvoiceDetailDAO.GetByMenuAndInvoice(invoiceId, menuId);
        }

        public DataTable GetByYear(int year)
        {
            return m_InvoiceDetailDAO.GetByYear(year);
        }

        public DataTable GetByMonth(int year, int month)
        {
            return m_InvoiceDetailDAO.GetByMonth(year, month);
        }

        public DataTable GetTopMenuYear(int year)
        {
            return m_InvoiceDetailDAO.GetTopMenuYear(year);
        }

        public DataTable GetTopMenuMonth(int year, int month)
        {
            return m_InvoiceDetailDAO.GetTopMenuMonth(year, month);
        }

        public int Add(InvoiceDetailInfo info)
        {
            return m_InvoiceDetailDAO.Add(info);
        }

        public int Update(InvoiceDetailInfo info)
        {
            return m_InvoiceDetailDAO.Update(info);
        }

        public int Delete(InvoiceDetailInfo info)
        {
            return m_InvoiceDetailDAO.Delete(info);
        }

        public int DeleteByInvoice(String invoiceId)
        {
            return m_InvoiceDetailDAO.DeleteByInvoice(invoiceId);
        }

        public DataRow AddNewRow()
        {
            return m_InvoiceDetailDAO.AddNewRow();
        }

        public void AddNewDetail(DataRow m_Row)
        {
            m_InvoiceDetailDAO.AddNewDetail(m_Row);
        }

        public bool SaveData()
        {
            return m_InvoiceDetailDAO.SaveData();
        }
    }
}
